<?php
error_reporting("E_ALL");ini_set("display_errors", 1);
$getdata=$_REQUEST;
if(empty($getdata))$getdata=$_POST?$_POST:$_GET;
$type=empty($getdata['type'])?'':$getdata['type'];
include("include/function.php");
//header("content-Type: application/json; charset=utf-8");
$config = include("config.php");
include("include/".$config['DB_TYPE'].".class.php");
$db = new db;
$db->connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD'],$config['DB_NAME'], $config['DB_PCONNECT']);

$schoollist = $db->get_all('select applet_id,name from hema_school');
$school=[];foreach($schoollist as $v){$school[$v['name']]=$v['applet_id'];}
$appletlist = $db->get_all('select applet_id,app_name from hema_applet');
$applet=[];foreach($appletlist as $v){$applet[$v['applet_id']]=$v['app_name'];}
$b = file('duibi/db.csv');
$barr=[];$new=[];
foreach($b as $v){
    $v = trim($v);
    $arr1=explode(',',$v);
    $name =trim($arr1[2]);
    $applet_id = !empty($school[$name])?$school[$name]:'';
    if($applet_id){
        $arr1[]=!empty($applet[$applet_id])?$applet[$applet_id]:'';
    }
    $new[]=implode(',',$arr1);
}

//echo count($sqlarr)."\n";
echo implode("\n",$new);
?>